#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void * print_msg( void *ptr );

main()
{
     pthread_t t1, t2;
     char *msg1 = "Sou a thread 1", 
          *msg2 = "Sou a thread 2";
     int  ret1, ret2;

     printf (" [%d] Sou o processo **iniciando**\n", getpid());
     ret1 = pthread_create( &t1, NULL, print_msg, (void*) msg1 );
     ret2 = pthread_create( &t2, NULL, print_msg, (void*) msg2 );
     pthread_join ( t1, NULL );
     pthread_join ( t2, NULL ); 
     printf("Thread 1 retorna: %d\n", ret1 );
     printf("Thread 2 retorna: %d\n", ret2 );
     printf (" [%d] Sou o processo ##terminando##\n", getpid());
     exit(0);
}

void *print_msg ( void *ptr )
{
     char *msg;

     msg = (char *) ptr;
     printf("[ proc %d thrd %u ] ===> %s \n", getpid(), (unsigned int) pthread_self(), msg);
     getchar();
     printf("[ proc %d thrd %u ] ===> %s \n", getpid(), (unsigned int) pthread_self(), msg);
}
